<?php
include("utils.php");

if($_POST['modecontact']=="contactus")
{
 	contact();
}
else
{
main_content("main();");
}

function contact()
{

if($_SESSION['langId']!="")
	{
		$langId=$_SESSION['langId'];
	}
	else
	{
		$langId="1";
	}
	$SEND=$_POST['Submit'];
	function check_input($value)
	{
	if( get_magic_quotes_gpc() )
	{
	$value = stripslashes( $value );
	}
	//check if this function exists
	if( function_exists( "mysql_real_escape_string" ) )
	{
	$value = mysql_real_escape_string( $value );
	}
	//for PHP version < 4.3.0 use addslashes
	else
	{
	$value = addslashes( $value );
	}
	return $value;
	}

//=============================================================================
	$CONTACTNAME=check_input($_POST['username']);
	$EMAIL=check_input($_POST['email']);
	$PHNO=check_input($_POST['phno']);
	$ADDRESS=check_input($_POST['address']);
	$CNTRY=check_input($_POST['Country']);
	$CITY=check_input($_POST['City']);
	$STATE=check_input($_POST['State']);
	$MESSAGE=check_input($_POST['message']);
	$today=date("Y-m-d");
	$IP=$_SERVER['REMOTE_ADDR'];
//==============================================================
	if(isset($SEND) && $SEND!= '')
		{ 

			$INSERquERycONTACT="INSERT INTO ".CONTACTUS." SET `langId`='".$langId."',`name`='".$CONTACTNAME."',`email`='".$EMAIL."',`phone1`='".$PHNO."',`address`='".$ADDRESS."',`city`='".$CITY."',`state`='".$STATE."',`country`='".$CNTRY."',`userIp`='".$IP."',`content`='".$MESSAGE."',`date`='".$today."',`answered`='N'";
$insertQuery=mysql_query($INSERquERycONTACT);

			$GLOBALS['contact']="Your Message Successfully Send To The Admin..";	

		}
			
	//header("Location:contact.php");

main_content("main();");
}



function main()
{
?>
<script language="javascript" src="JavaScripts/CHKcontactus.js"></script>

<input type="hidden" name="modecontact" value="contactus"><br />
<br />
<table width="90%" border="0" cellspacing="0" cellpadding="0">
              <tr>
                <td valign="top" align="center"><table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
                  <tr>
                    <td width="20%" valign="top"><?php include("left_pannel.php"); ?></td>
                    <td valign="top"><table width="827" border="0" cellspacing="0" cellpadding="0">
                  <tr>
                    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td width="11"><img src="images/PinkBorderTopLeft.jpg" alt="" width="11" height="11"></td>
                          <td class="PinkBoxTopBg"><img src="images/spacer.gif" alt="" width="10" height="11"></td>
                          <td width="11"><img src="images/PinkBorderTopRight.jpg" alt="" width="11" height="11"></td>
                        </tr>
                      </table></td>
                  </tr>
                  <tr>
                    <td class="PinkTwosideBorder BoxContent" valign="top" align="center"><form name="contact"  action="" method="POST" id="cont" onsubmit="return contact_chk();"><table width="100%" border="0" cellspacing="0" cellpadding="0">
				<tr><td colspan="2">&nbsp;</td></tr>
				<tr><td colspan="2" style="color:#FF0000; font-weight:bold;font-size:12px" align="center"><?php if($GLOBALS['contact']!=''){ echo $GLOBALS['contact'];} ?></td></tr>
                              <tr>
                                <td width="154" valign="top">&nbsp;</td>
                                <td valign="top"><table border="0" cellspacing="0" cellpadding="0">
                                  <tr>
                                    <td width="100" height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                      <tr>
                                        <td width="3"><img src="images/FormNameBoxLeft.jpg" alt="" width="3" height="18"></td>
                                        <td class="FormNameBoxBg">Your  Name:</td>
                                        <td width="13"><img src="images/FormNameBoxRight.jpg" alt="" width="13" height="18"></td>
                                      </tr>
                                    </table></td>
                                    <td width="14">&nbsp;</td>
                                    <td><input name="username" type="text" class="InputBox" id="UsernamE" value=""><span id="UserNameError" style="display:none; color:#FF0000; font-weight:bold; font-size:11px;"></span></td>
                                    <td width="11">&nbsp;</td>
                                    <td>&nbsp;</td>
                                  </tr>
                                  <tr>
                                    <td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                      <tr>
                                        <td width="3"><img src="images/FormNameBoxLeft.jpg" alt="" width="3" height="18"></td>
                                        <td class="FormNameBoxBg">Your E-Mail:</td>
                                        <td width="13"><img src="images/FormNameBoxRight.jpg" alt="" width="13" height="18"></td>
                                      </tr>
                                    </table></td>
                                    <td>&nbsp;</td>
                                    <td><input name="email" type="text" class="InputBox" id="EmaiL" value=""><span id="EmaiLError" style="display:none; color:#FF0000; font-weight:bold; font-size:11px;"></span></td>
                                    <td>&nbsp;</td>
                                    <td>&nbsp;</td>
                                  </tr>
                                  <tr>
                                    <td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                      <tr>
                                        <td width="3"><img src="images/FormNameBoxLeft.jpg" alt="" width="3" height="18"></td>
                                        <td class="FormNameBoxBg">Your Phone No:</td>
                                        <td width="13"><img src="images/FormNameBoxRight.jpg" alt="" width="13" height="18"></td>
                                      </tr>
                                    </table></td>
                                    <td>&nbsp;</td>
                                    <td><input name="phno" type="text" class="InputBox" id="phno" value=""><span id="phnoError" style="display:none; color:#FF0000; font-weight:bold; font-size:11px;"></span></td>
                                    <td>&nbsp;</td>
                                    <td>&nbsp;</td>
                                  </tr>
                                  <tr>
                                    <td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                      <tr>
                                        <td width="3"><img src="images/FormNameBoxLeft.jpg" alt="" width="3" height="18"></td>
                                        <td class="FormNameBoxBg">Your Address:</td>
                                        <td width="13"><img src="images/FormNameBoxRight.jpg" alt="" width="13" height="18"></td>
                                      </tr>
                                    </table></td>
                                    <td>&nbsp;</td>
                                    <td><input name="address" type="text" class="InputBox" id="address" value=""><span id="AddrError" style="display:none; color:#FF0000; font-weight:bold; font-size:11px;"></span></td>
                                    <td>&nbsp;</td>
                                    <td>&nbsp;</td>
                                  </tr>
                                  <tr>
                                    <td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                      <tr>
                                        <td width="3"><img src="images/FormNameBoxLeft.jpg" alt="" width="3" height="18"></td>
                                        <td class="FormNameBoxBg">Your Country:</td>
                                        <td width="13"><img src="images/FormNameBoxRight.jpg" alt="" width="13" height="18"></td>
                                      </tr>
                                    </table></td>
                                    <td>&nbsp;</td>
                                    <td><input name="Country" type="text" class="InputBox" id="Country" value="<?php echo $_POST['LastName'];?>"><span id="CountryError" style="display:none; color:#FF0000; font-weight:bold; font-size:11px;"></span></td>
                                    <td>&nbsp;</td>
                                    <td>&nbsp;</td>
                                  </tr>

                                  <tr>
                                    <td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                      <tr>
                                        <td width="3"><img src="images/FormNameBoxLeft.jpg" alt="" width="3" height="18"></td>
                                        <td class="FormNameBoxBg">Your State:</td>
                                        <td width="13"><img src="images/FormNameBoxRight.jpg" alt="" width="13" height="18"></td>
                                      </tr>
                                    </table></td>
                                    <td>&nbsp;</td>
                                    <td><input name="State" type="text" class="InputBox" id="State" value=""><span id="StateError" style="display:none; color:#FF0000; font-weight:bold; font-size:11px;"></span></td>
                                <td>&nbsp;</td>
                                    <td>&nbsp;</td>
                                  </tr>

                                  <tr>
                                    <td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                      <tr>
                                        <td width="3"><img src="images/FormNameBoxLeft.jpg" alt="" width="3" height="18"></td>
                                        <td class="FormNameBoxBg">Your City:</td>
                                        <td width="13"><img src="images/FormNameBoxRight.jpg" alt="" width="13" height="18"></td>
                                      </tr>
                                    </table></td>
                                    <td>&nbsp;</td>
                                    <td><input name="City" type="text" class="InputBox" id="City" value=""><span id="CityError" style="display:none; color:#FF0000; font-weight:bold; font-size:11px;"></span></td>
                                    <td>&nbsp;</td>
                                    <td>&nbsp;</td>
                                  </tr>
                                  <tr>
                                    <td height="30"><table width="100%" border="0" cellspacing="0" cellpadding="0">
                                      <tr>
                                        <td width="3"><img src="images/FormNameBoxLeft.jpg" alt="" width="3" height="18"></td>
                                        <td class="FormNameBoxBg">Your Message:</td>
                                        <td width="13"><img src="images/FormNameBoxRight.jpg" alt="" width="13" height="18"></td>
                                      </tr>
                                    </table></td>
                                    <td>&nbsp;</td>
                                    <td>
					  <textarea  name="message"  cols="35" rows="5" id="MeessagE"><?php // echo stripslashes($fetch['answer']);?></textarea><span id="MessagEError" style="display:none; color:#FF0000; font-weight:bold; font-size:11px;">
					
					  &nbsp; <span id="MessagEError" style="display:none; color:#FF0000; font-weight:bold; font-size:11px;"></span></td>
                                    <td>&nbsp;</td>
                                    <td>&nbsp;</td>
                                  </tr>

                                  <tr>
                                    <td height="30">&nbsp;</td>
                                    <td>&nbsp;</td>
                                    <td align="right" valign="bottom"><input name="Submit" type="submit" class="SubmitInputButton" id="submit" value="Send"></td>
                                    <td>&nbsp;</td>
                                    <td>&nbsp;</td>
                                  </tr>

                                </table></td>
                              </tr>
                            </table></form></td>
                  </tr>
                  <tr>
                    <td><table width="100%" border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td width="11"><img src="images/PinkBorderBottomLeft.jpg" alt="" width="11" height="11"></td>
                          <td class="PinkBoxBottomBg"><img src="images/spacer.gif" alt="" width="10" height="11"></td>
                          <td width="11"><img src="images/PinkBorderBottomRight.jpg" alt="" width="11" height="11"></td>
                        </tr>
                      </table></td>
                  </tr>
                </table></td>
                    <td>&nbsp;</td>
                    </tr>
                </table></td>
              </tr>
            </table>
<?php } ?>